home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 7
/
Apprentice-Release7.iso
/
Environments
/
Small Eiffel 0.4.8
/
lib_std
/
fixed_array2.e
< prev
next >
Wrap
Text File
|
1997-04-13
|
2KB
|
83 lines
-- Part of SmallEiffel -- Read DISCLAIMER file -- Copyright (C)
-- Dominique COLNET and Suzanne COLLIN -- colnet@loria.fr
--
class FIXED_ARRAY2[E]
--
-- Implementation of COLLECTION[E] with frozen lower bounds :
-- `lower1' and `lower2' are frozen to 0. Some memory is saved
-- and looping toward lower bounds runs a little bit faster.
--
inherit COLLECTION2[E] redefine copy end;
creation make, array2
feature {FIXED_ARRAY2}
storage: FIXED_ARRAY[like item];
feature
lower1, lower2: INTEGER is 0;
upper1, upper2, count1, count2: INTEGER;
feature
make(size1, size2: INTEGER) is
-- Reset `count1' and `count2' using arguments as new
-- values. All elements are set to the default value of
-- type E.
require
size1 > 0;
size2 > 0
do
count1 := size1;
count2 := size2;
if storage /= Void then
storage.free;
end;
upper1 := size1 - 1;
upper2 := size2 - 1;
!!storage.make(count);
ensure
count1 = size1;
count2 = size2;
upper1 = size1 - 1;
upper2 = size2 - 1
end;
feature
item(i1, i2: INTEGER): E is
do
Result := storage.item(i1 * count1 + i2);
end;
put(x: like item; i1, i2: INTEGER) is
do
storage.put(x,i1 * count1 + i2);
end;
copy(other: like Current) is
local
i: INTEGER;
do
make(other.count1,other.count2);
storage.copy(other.storage);
end;
invariant
upper1 > 0;
upper2 > 0;
count1 = upper1 + 1;
count2 = upper2 + 1;
storage.count = count;
end -- FIXED_ARRAY2